﻿<Window x:Class="LokumClient.Views.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:tb="http://www.hardcodet.net/taskbar"
        mc:Ignorable="d"
        Title="Lokum informer" Icon="..\Images\favicon.ico" WindowStartupLocation="CenterScreen"
        Height="150" Width="300" MinHeight="200" MinWidth="300">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close" Executed="CloseExecuted" />
        <CommandBinding Command="ApplicationCommands.Open" Executed="OpenSiteExecuted" />
        <CommandBinding Command="NavigationCommands.Refresh" Executed="UpdateInfoExecuted" />
    </Window.CommandBindings>
    <Grid Name="MainGrid" d:DataContext="{d:DesignData viewModels:MainViewModel}">
        <Grid.Resources>
            <Style TargetType="Button" x:Key="RedButton">
                <Setter Property="Background" Value="Red" />
                <Setter Property="Foreground" Value="White" />
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="Width" Value="75" />
                <Setter Property="Height" Value="35" />
                <Setter Property="VerticalAlignment" Value="Bottom" />
                <Setter Property="HorizontalAlignment" Value="Right" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Border Background="{TemplateBinding Background}">
                                <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                            </Border>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="Black" />
                    </Trigger>
                </Style.Triggers>
            </Style>
            <Style TargetType="{x:Type Label}" x:Key="BoldLabel">
                <Setter Property="FontWeight" Value="Bold" />
                <Setter Property="HorizontalAlignment" Value="Left" />
                <Setter Property="VerticalAlignment" Value="Top" />
            </Style>
            <Border x:Key="ToolTipBorder"
                    Background="Red"
                    BorderBrush="White"
                    BorderThickness="2"
                    CornerRadius="4"
                    Width="190"
                    Height="100">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                        <RowDefinition />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <Label Content="Lokum informer"
                           Foreground="White"
                           Style="{StaticResource BoldLabel}"
                           HorizontalAlignment="Center"
                           Grid.ColumnSpan="2" />
                    <Label Content="Last update: "
                           Foreground="White"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="1"
                           Grid.Column="0" />
                    <Label Content="{Binding UpdateDateTime}"
                           ContentStringFormat="{}{0:dd.MM HH:mm}"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="1"
                           Grid.Column="1" />
                    <Label Content="Status: "
                           Foreground="White"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="2"
                           Grid.Column="0" />
                    <Label Content="{Binding Status}"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="2"
                           Grid.Column="1" />
                    <Label Content="Flats count: "
                           Foreground="White"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="3"
                           Grid.Column="0" />
                    <Label Content="{Binding FlatsCount}"
                           Style="{StaticResource BoldLabel}"
                           Grid.Row="3"
                           Grid.Column="1" />
                </Grid>
            </Border>
            <Border x:Key="PopUpBorder"
                    Background="Red"
                    BorderBrush="White"
                    BorderThickness="2"
                    CornerRadius="4"
                    Width="200"
                    Height="40">
                <Button Content="Open Lokum site"
                        Style="{StaticResource RedButton}"
                        Width="120"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Command="{Binding ApplicationCommands.Open}" />
            </Border>
            <ContextMenu x:Key="TrayContextMenu"
                         Background="Red"
                         Foreground="White"
                         FontWeight="Bold"
                         BorderBrush="White"
                         BorderThickness="2">
                <MenuItem Header="Update info" Command="{Binding NavigationCommands.Refresh}" Background="Red">
                    <MenuItem.Icon>
                        <Image Source="..\Images\112_RefreshArrow_Blue.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Name="showMenuItem" Command="{Binding ShowHideMainWindowCommand}" CommandParameter="true"
                          Header="Show main window" Background="Red">
                    <MenuItem.Icon>
                        <Image Source="..\Images\125_FullView.ico" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Name="exitMenuItem" Command="{Binding ApplicationCommands.Close}" Header="Exit program"
                          Background="Red">
                    <MenuItem.Icon>
                        <Image Source="..\Images\Close.ico" />
                    </MenuItem.Icon>
                </MenuItem>
            </ContextMenu>
        </Grid.Resources>
        <tb:TaskbarIcon x:Name="NotifyIcon"
                        IconSource="/Images/favicon.ico"
                        Visibility="Visible"
                        ToolTipText="Lokum notifier"
                        PopupActivation="DoubleClick"
                        MenuActivation="LeftOrRightClick"
                        TrayPopup="{StaticResource PopUpBorder}"
                        TrayToolTip="{StaticResource ToolTipBorder}"
                        ContextMenu="{StaticResource TrayContextMenu}" />

        <Image HorizontalAlignment="Left" Height="83" Margin="10,10,0,0" VerticalAlignment="Top" Width="224"
               Source="..\Images\logo-big_0.png" />

        <Label Content="Last update: " Foreground="Red" Margin="10,75,0,0" Style="{StaticResource BoldLabel}" />
        <Label Content="{Binding UpdateDateTime}" ContentStringFormat="{}{0:yyyy-MM-dd HH:mm:ss}" Margin="92,75,0,0"
               Style="{StaticResource BoldLabel}" />

        <Label Content="Status: " Foreground="Red" Margin="10,92,0,0" Style="{StaticResource BoldLabel}" />
        <Label Content="{Binding Status}" Margin="92,92,0,0" Style="{StaticResource BoldLabel}" />

        <Label Content="Flats: " Foreground="Red" Margin="210,92,0,0" Style="{StaticResource BoldLabel}" />
        <Label Content="{Binding FlatsCount}" Margin="250,92,0,0" Style="{StaticResource BoldLabel}" />

        <Button Content="Exit" Command="{Binding ApplicationCommands.Close}" Style="{StaticResource RedButton}"
                Margin="0,0,10.4,9.8" />
        <Button Content="Hide" Command="{Binding ShowHideMainWindowCommand}" Style="{StaticResource RedButton}"
                Margin="0,0,108.4,9.8" />
        <Button Content="Update" Command="{Binding NavigationCommands.Refresh}" Style="{StaticResource RedButton}"
                Margin="0,0,188.6,9.8" />
    </Grid>
</Window>